package com.example.hcd.internet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.example.hcd.datamanage.BorrowData;
import com.example.hcd.datamanage.BusniessTravelData;
import com.example.hcd.datamanage.DepartmentData;
import com.example.hcd.datamanage.LeaveData;
import com.example.hcd.datamanage.NoticeData;
import com.example.hcd.datamanage.OutData;
import com.example.hcd.datamanage.OverTimeData;
import com.example.hcd.datamanage.PaymentData;
import com.example.hcd.datamanage.PurchaseData;
import com.example.hcd.datamanage.ReimburseData;
import com.example.hcd.datamanage.RoleInfoData;
import com.example.hcd.datamanage.SealuseData;
import com.example.hcd.datamanage.TaskTodoInfo;
import com.example.hcd.datamanage.UserInfoData;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

public class InternetKeep {

    private static InternetKeep internet;
    // 公章信息列表
    private ArrayList<SealInfo> sealInfolist;
    // 部门信息列表
    private ArrayList<DepartmentData> departmentInfolist;
    // 采购类型列表
    private ArrayList<Pur_Pay_Proj_Info> purchaseTypelist;
    // 付款类型列表
    private ArrayList<Pur_Pay_Proj_Info> payTypeInfolist;
    // 用户信息列表
    private ArrayList<UserInfoData> userinfolist;
    // 项目信息列表
    private ArrayList<Pur_Pay_Proj_Info> projectInfolist;
    // 角色信息列表
    private ArrayList<RoleInfoData> roleInfolist;

    //报销列表
    //private ArrayList<ReimburseData> reimburseList = new ArrayList<ReimburseData>();
    //报销列表缓存
    private ArrayList<ReimburseData> reimburseListCatch = new ArrayList<ReimburseData>();

    //待办任务列表
    //private ArrayList<TaskTodoInfo> taskTodoInfoList = new ArrayList<TaskTodoInfo>();
    //待办任务缓存
    private ArrayList<TaskTodoInfo> taskTodoInfoListCatch = new ArrayList<TaskTodoInfo>();

    //付款列表缓存
    private ArrayList<PaymentData> paymentListCatch = new ArrayList<PaymentData>();
    //借款列表緩存
    private ArrayList<BorrowData> borrowListCatch = new ArrayList<BorrowData>();
    //采购列表缓存
    private ArrayList<PurchaseData> purchaseListCatch = new ArrayList<PurchaseData>();
    //用章列表缓存
    private ArrayList<SealuseData> sealuseListCatch = new ArrayList<SealuseData>();
    //公告列表信息
    private ArrayList<NoticeData> noticeListCatch = new ArrayList<NoticeData>();
    private ArrayList<NoticeData> noticeList = new ArrayList<NoticeData>();

    //加班类表缓存
    private ArrayList<OverTimeData> overtimeListCatch = new ArrayList<OverTimeData>();
    //请假类表缓存
    private ArrayList<LeaveData> leaveListCatch = new ArrayList<LeaveData>();

    //外出类表缓存
    private ArrayList<OutData> outListCatch = new ArrayList<OutData>();

    //出差类表缓存
    private ArrayList<BusniessTravelData> businessListCatch = new ArrayList<BusniessTravelData>();

    //考勤列表缓存
    private ArrayList<UserInfoData> signListCatch = new ArrayList<UserInfoData>();


    private Context contexts;

    public String cookie;

    public int appVersion;

    // 系统信息是加载
    public boolean isSystemInfoLoad = false;
    //是否还有下一页
    public boolean isHaveNextPage = false;


    public int getVersionCode() {
        return appVersion;
    }

    public void setVersionCode(int versionCode) {
        this.appVersion = versionCode;
    }


    public void clearCacheData() {
        reimburseListCatch.clear();
        isHaveNextPage = false;
        //getTaskTodoInfoList().clear();
        taskTodoInfoListCatch.clear();
        paymentListCatch.clear();
        borrowListCatch.clear();
        purchaseListCatch.clear();
        noticeListCatch.clear();
        overtimeListCatch.clear();
        leaveListCatch.clear();
        outListCatch.clear();
        businessListCatch.clear();
        getSignListCatch().clear();
    }

    public static InternetKeep getInstence() {
        if (internet == null) {
            internet = new InternetKeep();
        }
        return internet;
    }

    // 获取系统信息
    public boolean getSystemInfo() {
        if (isSystemInfoLoad) {
            return true;
        }

        Thread hot = new Thread(new Runnable() {
            @Override
            public void run() {
                HttpResponse response = null;
                BufferedReader reader = null;

                try {
                    response = LinkHelp.post(URLS.getSystemInfo(), null, true);
                    if (response != null) {
                        StatusLine line = response.getStatusLine();
                        if (line.getStatusCode() == 200) {
                            reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                            StringBuilder sb = new StringBuilder();
                            for (String s = reader.readLine(); s != null; s = reader.readLine()) {
                                sb.append(s);
                            }

                            if (!TextUtils.isEmpty(sb)) {
                                String result = sb.toString();
                                if (result.contains("error")) {
//									Toast.makeText(contexts, "获取系统信息失败",
//									 Toast.LENGTH_SHORT).show();
                                    isSystemInfoLoad = false;
//									Log.e("NAME","DAOWOLE2");

                                } else {
//									 Toast.makeText(contexts, "获取系统信息成功",
//									 Toast.LENGTH_SHORT).show();
//									Log.e("NAME","DAOWOLE");
                                    ParseSystemInfo(result);
                                    isSystemInfoLoad = true;

//									Intent intent = new Intent(contexts, MenuActivity.class);
//									contexts.startActivity(intent);


                                }

                            }

                        }
                    } else {

                        isSystemInfoLoad = false;
                    }
                } catch (Exception e) {

                } finally {
                    if (reader != null) {
                        try {
                            reader.close();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }

            }
        });
        hot.start();

        return isSystemInfoLoad;
    }

    public void ParseSystemInfo(String result) throws JSONException {

        SimpleDateFormat mFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");

        // 公章信息列表
        sealInfolist = new ArrayList<SealInfo>();
        // 部门信息列表
        departmentInfolist = new ArrayList<DepartmentData>();
        // 采购类型列表
        purchaseTypelist = new ArrayList<Pur_Pay_Proj_Info>();
        // 付款类型列表
        payTypeInfolist = new ArrayList<Pur_Pay_Proj_Info>();
        // 用户信息列表
        userinfolist = new ArrayList<UserInfoData>();
        // 项目信息列表
        projectInfolist = new ArrayList<Pur_Pay_Proj_Info>();
        // 角色信息列表
        roleInfolist = new ArrayList<RoleInfoData>();
        // 解析系统数据
        JSONObject object = new JSONObject(result);

        if (!object.isNull("app_version")) {
            appVersion = object.getInt("app_version");
        }




        // 解析角色列表
        JSONArray jsonRoleArr = object.getJSONArray("roleList");

        sealInfolist.clear();
        for (int i = 0; i < jsonRoleArr.length(); i++) {
            JSONObject jsonRole = jsonRoleArr.getJSONObject(i);
            RoleInfoData roleInfo = new RoleInfoData();
            roleInfo.setId(jsonRole.getString("id"));
            long time = jsonRole.getLong("createTime");
            roleInfo.setCreateTime(mFormat.format(new Date(time)));
            time = jsonRole.isNull("modifyTime") ? 0 : jsonRole.getLong("modifyTime");
            roleInfo.setModifyTime(mFormat.format(new Date(time)));
            roleInfo.setRoleName(jsonRole.getString("roleName"));
            roleInfo.setRole_code(jsonRole.getString("role_code"));

            roleInfolist.add(roleInfo);
        }

        // 解析公章信息列表
        sealInfolist.clear();
        String sealList = object.getString("sealList");
        sealList = sealList.subSequence(1, sealList.length() - 1).toString();
        String[] seas = sealList.split(",");
        for (int i = 0; i < seas.length; i++) {
            String sealInfostr = seas[i];
            sealInfostr = sealInfostr.subSequence(1, sealInfostr.length() - 1).toString();
            SealInfo sealInfo = new SealInfo();
            sealInfo.sealName = sealInfostr;
            sealInfolist.add(sealInfo);

        }

        // 解析部门信息列表
        departmentInfolist.clear();
        JSONArray jsonDepArr = new JSONObject(result).getJSONArray("departmentList");
        for (int i = 0; i < jsonDepArr.length(); i++) {
            JSONObject jsonDep = jsonDepArr.getJSONObject(i);
            DepartmentData departmentInfo = new DepartmentData();
            departmentInfo.id = jsonDep.getString("id");
            departmentInfo.name = jsonDep.getString("name");
            departmentInfo.parent_id = jsonDep.getString("parent_id");
            departmentInfo.parent_name = jsonDep.isNull("parent_name") ? "" : jsonDep.getString("parent_name");
            departmentInfo.leaderId = jsonDep.isNull("leaderId") ? "" : jsonDep.getString("leaderId");
            departmentInfo.companyId = jsonDep.getString("companyId");
            departmentInfolist.add(departmentInfo);
        }
        // 解析采购类型列表
        purchaseTypelist.clear();
        JSONObject jsonPurc = new JSONObject(result).getJSONObject("purchaseType");
        Iterator<String> its = jsonPurc.keys();
        while (its.hasNext()) {
            String key = its.next();
            Pur_Pay_Proj_Info purInfo = new Pur_Pay_Proj_Info();
            purInfo.pur_Pay_Proj_Info = key;
            purInfo.id = jsonPurc.getString(key);
            purchaseTypelist.add(purInfo);
        }
        purchaseTypelist = SortById(purchaseTypelist);
        // 解析付款类型列表
        payTypeInfolist.clear();
        JSONObject jsonPay = new JSONObject(result).getJSONObject("payformentType");
        Iterator<String> itss = jsonPay.keys();
        while (itss.hasNext()) {
            String key = itss.next();
            Pur_Pay_Proj_Info payInfo = new Pur_Pay_Proj_Info();
            payInfo.pur_Pay_Proj_Info = key;
            payInfo.id = jsonPay.getString(key);
            payTypeInfolist.add(payInfo);
        }

        payTypeInfolist = SortById(payTypeInfolist);

        // 解析项目信息列表
        projectInfolist.clear();
        JSONObject jsonProj = new JSONObject(result).getJSONObject("projectList");

        Iterator<String> it = jsonProj.keys();
        while (it.hasNext()) {
            String key = it.next();
            Pur_Pay_Proj_Info projInfo = new Pur_Pay_Proj_Info();
            projInfo.pur_Pay_Proj_Info = key;
            projInfo.id = jsonProj.getString(key);
            projectInfolist.add(projInfo);
        }
        projectInfolist = SortById(projectInfolist);


        // 解析用户信息列表
        userinfolist.clear();
        JSONArray jsonUserArr = new JSONObject(result).getJSONArray("userList");
        for (int i = 0; i < jsonUserArr.length(); i++) {
            JSONObject jsonUser = jsonUserArr.getJSONObject(i);
            UserInfoData userInfo = new UserInfoData();

            userInfo.name = jsonUser.getString("name");
            userInfo.mobileNumber = jsonUser.getString("mobileNumber");
            userInfo.id = jsonUser.getString("id");
            userInfo.email = jsonUser.isNull("jsonUser") ? "" : jsonUser.getString("email");

            userinfolist.add(userInfo);
        }

        Log.e("userinfolist.size()=" , userinfolist.size()+"");

    }

    public void parseNoticeList(String results) {
        try {
            JSONObject obj = new JSONObject(results);
            JSONArray notice = obj.getJSONArray("notificationList");
            JSONObject file = obj.getJSONObject("fileMap");
            String filestr = obj.getString("fileMap");
            String isHaveNext = obj.getString("arriveEnd");
            String imgPrefix = obj.getString("imgPrefix");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            noticeListCatch.clear();
            for (int i = 0; i < notice.length(); i++) {
                NoticeData data = new NoticeData();
                JSONObject myJs = notice.getJSONObject(i);
                data.setId(myJs.getString("id"));
                data.setContent(myJs.getString("content"));
                data.setTitle(myJs.getString("title"));
                data.setIs_sticky_post(myJs.getString("is_sticky_post"));
                data.setSticky_post_days(myJs.isNull("sticky_post_days") ? null : myJs.getString("sticky_post_days"));
                data.setInvalid_date(myJs.isNull("invalid_date") ? null : myJs.getString("invalid_date"));
                data.setKeywords(myJs.getString("keywords"));
                data.setCreate_time(myJs.getString("create_time"));
                data.setCreate_by(myJs.getString("create_by"));
                data.setModify_by(myJs.isNull("modify_by") ? "" : myJs.getString("modify_by"));
                data.setModify_time(myJs.isNull("modify_time") ? null : myJs.getString("modify_time"));
                data.setCreate_id(myJs.getString("create_id"));
                data.setDeparts_id(myJs.isNull("departs_id") ? null : myJs.getString("departs_id"));
                data.setUsers_id(myJs.isNull("users_id") ? null : myJs.getString("users_id"));
                data.setRoles_id(myJs.isNull("roles_id") ? null : myJs.getString("roles_id"));
                data.setImgPrefix(imgPrefix);

                if (filestr.contains(data.getId())) {
                    JSONArray filelist = file.getJSONArray(data.getId());
                    for (int j = 0; j < filelist.length(); j++) {
                        String key = filelist.get(j).toString();
                        if (FileUtils.isPic(key)) {
                            data.getPicList().add(key);
                        } else {
                            data.getFileList().add(key);
                        }

                    }

                }

                noticeList.add(data);
                noticeListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public ArrayList<SealInfo> getSealInfolist() {
        return sealInfolist;
    }

    public void setSealInfolist(ArrayList<SealInfo> sealInfolist) {
        this.sealInfolist = sealInfolist;
    }

    public ArrayList<DepartmentData> getDepartmentInfolist() {
        return departmentInfolist;
    }

    public void setDepartmentInfolist(ArrayList<DepartmentData> departmentInfolist) {
        this.departmentInfolist = departmentInfolist;
    }

    public ArrayList<Pur_Pay_Proj_Info> getPurchaseTypelist() {
        return purchaseTypelist;
    }

    public void setPurchaseTypelist(ArrayList<Pur_Pay_Proj_Info> purchaseTypelist) {
        this.purchaseTypelist = purchaseTypelist;
    }

    public ArrayList<Pur_Pay_Proj_Info> getPayTypeInfolist() {
        return payTypeInfolist;
    }

    public void setPayTypeInfolist(ArrayList<Pur_Pay_Proj_Info> payTypeInfolist) {
        this.payTypeInfolist = payTypeInfolist;
    }

    public ArrayList<UserInfoData> getUserinfolist() {
        return userinfolist;
    }

    public void setUserinfolist(ArrayList<UserInfoData> userinfolist) {
        this.userinfolist = userinfolist;
    }

    public ArrayList<Pur_Pay_Proj_Info> getProjectInfolist() {
        return projectInfolist;
    }

    public void setProjectInfolist(ArrayList<Pur_Pay_Proj_Info> projectInfolist) {
        this.projectInfolist = projectInfolist;
    }

    public ArrayList<RoleInfoData> getRoleInfolist() {
        return roleInfolist;
    }

    public void setRoleInfolist(ArrayList<RoleInfoData> roleInfolist) {
        this.roleInfolist = roleInfolist;
    }

    // 用章信息
    public class SealInfo {
        public String sealName;
    }

    public String getPayTypeByID(String Id) {
        String type = "";
        for (int i = 0; i < purchaseTypelist.size(); i++) {
            Pur_Pay_Proj_Info info = purchaseTypelist.get(i);

            if (info.id.equals(Id)) {
                type = info.pur_Pay_Proj_Info;
            }
        }

        return type;
    }

    public String getIdBypay1Type(String Type) {
        String id = null;
        for (int i = 0; i < payTypeInfolist.size(); i++) {
            Pur_Pay_Proj_Info info = payTypeInfolist.get(i);

            if (info.pur_Pay_Proj_Info.equals(Type)) {
                id = info.id;
            }
        }

        return id;
    }

    public String getIdBypayType(String Type) {
        String id = null;
        for (int i = 0; i < purchaseTypelist.size(); i++) {
            Pur_Pay_Proj_Info info = purchaseTypelist.get(i);

            if (info.pur_Pay_Proj_Info.equals(Type)) {
                id = info.id;
            }
        }

        return id;
    }

    public String getIdByprojectName(String name) {
        String id = null;
        for (int i = 0; i < projectInfolist.size(); i++) {
            Pur_Pay_Proj_Info info = projectInfolist.get(i);

            if (info.pur_Pay_Proj_Info.equals(name)) {
                id = info.id;
            }
        }

        return id;
    }

    public String getprojectNameById(String Id) {
        String name = null;
        for (int i = 0; i < projectInfolist.size(); i++) {
            Pur_Pay_Proj_Info info = projectInfolist.get(i);

            if (info.id.equals(Id)) {
                name = info.pur_Pay_Proj_Info;
            }
        }

        return name;
    }


    // 采购类型 付款类型 项目信息
    public class Pur_Pay_Proj_Info {
        public String pur_Pay_Proj_Info;
        public String id;
    }

    public ArrayList<Pur_Pay_Proj_Info> SortById(ArrayList<Pur_Pay_Proj_Info> infolist) {
        for (int i = 0; i < infolist.size(); i++)
            for (int j = 0; j < infolist.size() - 1; j++) {
                int key1 = Integer.parseInt(infolist.get(j).id);
                int key2 = Integer.parseInt(infolist.get(j + 1).id);

                if (key1 > key2) {
                    Pur_Pay_Proj_Info temp = new Pur_Pay_Proj_Info();

                    temp.pur_Pay_Proj_Info = infolist.get(j).pur_Pay_Proj_Info;
                    temp.id = infolist.get(j).id;

                    infolist.get(j).pur_Pay_Proj_Info = infolist.get(j + 1).pur_Pay_Proj_Info;
                    infolist.get(j).id = infolist.get(j + 1).id;

                    infolist.get(j + 1).pur_Pay_Proj_Info = temp.pur_Pay_Proj_Info;
                    infolist.get(j + 1).id = temp.id;
                }
            }

        return infolist;

    }

    //	// 角色信息
//	public class RoleInfo {
//		// 角色id
//		public String id;
//		// 角色创建时间
//		public String createTime;
//		// 角色修改时间
//		public String modifyTime;
//		// 角色称号
//		public String roleName;
//		// 角色权限
//		public String role_code;
//	}
    public void ParseReimburseList(String results) {
        //System.out.println(results);
        JSONArray Reimburse;
        try {
            JSONObject obj = new JSONObject(results);
            Reimburse = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            getReimburseListCatch().clear();
            for (int i = 0; i < Reimburse.length(); i++) {
                ReimburseData data = new ReimburseData(null);
                JSONObject myJs = Reimburse.getJSONObject(i);
                data.setId(myJs.getString("id"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setProcessDefinitionId(myJs.isNull("processDefinitionId") ? null : myJs.getString("processDefinitionId"));
                data.setTitle(myJs.getString("title"));
                data.setRemark(myJs.isNull("remark") ? null : myJs.getString("remark"));
                data.setUserId(myJs.getString("userId"));
                data.setProjectName(myJs.getString("projectName"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setCreatetime(myJs.getLong("createtime"));
                data.setApplicant(myJs.getString("applicant"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                data.setAmount(myJs.getDouble("amount"));
                //reimburseList.add(data);
                if (data.getProcessStatusValue().equals("0")) {

                } else
                    getReimburseListCatch().add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }


    public void ParseTaskTodoList(String results) {
        JSONArray taskTodo;
        try {
            JSONObject obj = new JSONObject(results);
            taskTodo = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            getTaskTodoInfoListCatch().clear();
            for (int i = 0; i < taskTodo.length(); i++) {
                TaskTodoInfo data = new TaskTodoInfo();
                JSONObject myJs = taskTodo.getJSONObject(i);
                data.setUserName(myJs.getString("userName"));
                data.setTitle(myJs.getString("title"));
                data.setKey(myJs.getString("key"));
                data.setProcessDefinitionName(myJs.getString("processDefinitionName"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                data.setProc_INST_ID_(myJs.getString("proc_INST_ID_"));
                data.setProc_DEF_ID_(myJs.getString("proc_DEF_ID_"));
                data.setName_(myJs.getString("name_"));
                data.setId_(myJs.getString("id_"));
                data.setUser_ID_(myJs.getString("user_ID_"));
                data.setTask_DEF_KEY_(myJs.getString("task_DEF_KEY_"));
                data.setAssignee_(myJs.getString("assignee_"));
                data.setCreate_TIME_(myJs.getLong("create_TIME_"));

                //taskTodoInfoList.add(data);
                taskTodoInfoListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }


    public void ParseMyProcess(String results) {
        JSONArray taskTodo;
        try {
            JSONObject obj = new JSONObject(results);
            taskTodo = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            getTaskTodoInfoListCatch().clear();
            for (int i = 0; i < taskTodo.length(); i++) {
                TaskTodoInfo data = new TaskTodoInfo();
                JSONObject myJs = taskTodo.getJSONObject(i);
                data.setUserName(myJs.getString("name"));
                data.setTitle(myJs.getString("title"));
                data.setKey(myJs.getString("key"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                data.setProc_INST_ID_(myJs.getString("proc_INST_ID_"));
                data.setProc_DEF_ID_(myJs.getString("proc_DEF_ID_"));
                data.setName_(myJs.getString("name_"));
                data.setBussiness_key(myJs.getString("business_KEY_"));
                data.setStart_user_id(myJs.getString("start_USER_ID_"));
                data.setStart_time(myJs.getString("start_TIME_"));
                data.setEnd_time(myJs.isNull("end_TIME_") ? null : myJs.getString("end_TIME_"));
                data.setDelete_reason(myJs.isNull("delete_REASON_") ? null : myJs.getString("delete_REASON_"));
                //taskTodoInfoList.add(data);
                taskTodoInfoListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }


    public void ParsePaymentList(String results) {
        JSONArray payment;
        try {
            JSONObject obj = new JSONObject(results);
            payment = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            getPaymentListCatch().clear();
            for (int i = 0; i < payment.length(); i++) {
                PaymentData data = new PaymentData(null);
                JSONObject myJs = payment.getJSONObject(i);
                data.setId(myJs.getString("id"));
                data.setTitle(myJs.getString("title"));
                data.setActionTime(myJs.getString("actiontime"));
                data.setGatheringManName(myJs.getString("gatheringManName"));
                data.setGatheringManId(myJs.getString("gatheringManId"));
                data.setApplyPeopleId(myJs.getString("userid"));
                data.setBankName(myJs.getString("bankName"));
                data.setBankCardId(myJs.getString("bankCardId"));
                data.setReason(myJs.getString("reason"));
                data.setTaxNumber(myJs.getString("taxNumber"));
                data.setAmount(new BigDecimal(myJs.getString("amount")));
                data.setProcessId(myJs.getString("processInstanceId"));
                data.setFileName(myJs.getString("filename"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusId(myJs.getString("processStatusValue"));
                data.setType(myJs.isNull("typeName") ? "" : myJs.getString("typeName"));
                data.setApplicant(myJs.getString("applicant"));

                paymentListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParseBorrowList(String results) {
        JSONArray borrow;
        try {
            JSONObject obj = new JSONObject(results);
            borrow = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            getBorrowData().clear();
            for (int i = 0; i < borrow.length(); i++) {
                BorrowData data = new BorrowData(null);
                JSONObject myJs = borrow.getJSONObject(i);
                data.setID(myJs.getString("id"));
                data.setApplicant(myJs.getString("applicant"));
                data.setTitle(myJs.getString("title"));
                data.setAmount(myJs.getString("amount"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setBorrowTime(myJs.getString("borrowTime"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));

                borrowListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParseSignList(String results) {
        JSONArray sign;
        try {
            JSONObject obj = new JSONObject(results);
            sign = obj.getJSONArray("userlist");

            JSONObject sign_other = obj.getJSONObject("request_pageView");

            String allpage = sign_other.isNull("totalPage") ? "0" : sign_other.getString("totalPage");

            String currentPage = sign_other.isNull("currentPage") ? "0" : sign_other.getString("currentPage");

            if (Integer.parseInt(currentPage) >= Integer.parseInt(allpage)) {
                isHaveNextPage = true;
            } else {
                isHaveNextPage = false;
            }
            getSignListCatch().clear();
            for (int i = 0; i < sign.length(); i++) {
                UserInfoData data = new UserInfoData();
                JSONObject myJs = sign.getJSONObject(i);

                data.id = myJs.getString("id");
                data.name = myJs.getString("name");
                data.department = myJs.isNull("departmentName") ? "" : myJs.getString("departmentName");
                data.lateNum = myJs.isNull("lateNum") ? 0 : myJs.getLong("lateNum");
                data.earlyNum = myJs.isNull("earlyNum") ? 0 : myJs.getLong("earlyNum");
                data.overWorkHours = myJs.isNull("overWorkHours") ? "0" : myJs.getString("overWorkHours");

                getSignListCatch().add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParseOverTimeList(String results) {
        JSONArray overtime;
        try {
            JSONObject obj = new JSONObject(results);
            overtime = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            getOvertimeListCatch().clear();
            for (int i = 0; i < overtime.length(); i++) {
                OverTimeData data = new OverTimeData();
                JSONObject myJs = overtime.getJSONObject(i);
                data.setID(myJs.getString("id"));
                data.setApplicant(myJs.getString("applicant"));
                data.setOvertimeReason(myJs.getString("reason"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setCreateTime(myJs.getString("createtime"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                data.setName(myJs.getString("username"));
                data.setStartTime(myJs.getString("startDate"));
                data.setEndTime(myJs.getString("endDate"));

                getOvertimeListCatch().add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParseLeaveList(String results) {
        JSONArray leave;
        try {
            JSONObject obj = new JSONObject(results);
            leave = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            leaveListCatch.clear();
            for (int i = 0; i < leave.length(); i++) {
                LeaveData data = new LeaveData();
                JSONObject myJs = leave.getJSONObject(i);
                data.setID(myJs.getString("id"));
                data.setApplicant(myJs.getString("applicant"));
                data.setReason(myJs.getString("reason"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setCreateTime(myJs.getString("createtime"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                data.setName(myJs.getString("username"));
                data.setStartTime(myJs.getString("startDate"));
                data.setEndTime(myJs.getString("endDate"));
                leaveListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParseOutList(String results) {
        JSONArray out;
        try {
            JSONObject obj = new JSONObject(results);
            out = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            outListCatch.clear();
            for (int i = 0; i < out.length(); i++) {
                OutData data = new OutData();
                JSONObject myJs = out.getJSONObject(i);
                data.setID(myJs.getString("id"));
                data.setApplicant(myJs.getString("applicant"));
                data.setReason(myJs.getString("reason"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setCreateTime(myJs.getString("createtime"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                data.setName(myJs.getString("username"));
                data.setStartTime(myJs.getString("startDate"));
                data.setEndTime(myJs.getString("endDate"));
                outListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParseBusinessList(String results) {
        JSONArray busin;
        try {
            JSONObject obj = new JSONObject(results);
            busin = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            getBusinessListCatch().clear();
            for (int i = 0; i < busin.length(); i++) {
                BusniessTravelData data = new BusniessTravelData();
                JSONObject myJs = busin.getJSONObject(i);
                data.setID(myJs.getString("id"));
                data.setApplicant(myJs.getString("applicant"));
                data.setReason(myJs.getString("reason"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setCreateTime(myJs.getString("actiontime"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                data.setName(myJs.getString("username"));
                data.setStartTime(myJs.getString("startDate"));
                data.setEndTime(myJs.getString("endDate"));

                data.setToAddress(myJs.getString("toAddress"));
                data.setTranType(myJs.getString("tranType"));
                data.setProjectName(myJs.getString("projectName"));

                getBusinessListCatch().add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParsePurchaseList(String results) {
        JSONArray purchase;
        try {
            JSONObject obj = new JSONObject(results);
            purchase = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            purchaseListCatch.clear();
            for (int i = 0; i < purchase.length(); i++) {
                PurchaseData data = new PurchaseData(null);
                JSONObject myJs = purchase.getJSONObject(i);
                data.setID(myJs.getString("id"));
                data.setApplicant(myJs.getString("applicant"));
                data.setTitle(myJs.getString("title"));
                data.setAmount(myJs.getString("amount"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setPurchaseTime(myJs.isNull("purchaseTime") ? null : myJs.getString("purchaseTime"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));

                purchaseListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

    public void ParseSealuseList(String results) {
        JSONArray sealuse;
        try {
            JSONObject obj = new JSONObject(results);
            sealuse = obj.getJSONArray("list");

            String isHaveNext = obj.getString("arriveEnd");
            if (isHaveNext.equals("true")) {
                isHaveNextPage = true;
            } else if (isHaveNext.equals("false")) {
                isHaveNextPage = false;
            }
            sealuseListCatch.clear();
            for (int i = 0; i < sealuse.length(); i++) {
                SealuseData data = new SealuseData(null);
                JSONObject myJs = sealuse.getJSONObject(i);
                data.setId(myJs.getString("id"));
                data.setSealName(myJs.getString("sealType"));
                data.setProcessInstanceId(myJs.getString("processInstanceId"));
                data.setCreatetime(myJs.getString("createtime"));
                data.setProcessStatus(myJs.getString("processStatus"));
                data.setApplicant(myJs.getString("applicant"));
                data.setProcessStatusValue(myJs.getString("processStatusValue"));
                sealuseListCatch.add(data);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }

//	public ArrayList<ReimburseData> getReimburseList() {
//		return reimburseList;
//	}
//
//	public void setReimburseList(ArrayList<ReimburseData> myReimburseList) {
//		this.reimburseList = myReimburseList;
//	}


    public ArrayList<ReimburseData> getReimburseListCatch() {
        return reimburseListCatch;
    }

    public void setReimburseListCatch(ArrayList<ReimburseData> reimburseListCatch) {
        this.reimburseListCatch = reimburseListCatch;
    }

    public ArrayList<TaskTodoInfo> getTaskTodoInfoListCatch() {
        return taskTodoInfoListCatch;
    }

    public void setTaskTodoInfoListCatch(ArrayList<TaskTodoInfo> taskTodoInfoListCatch) {
        this.taskTodoInfoListCatch = taskTodoInfoListCatch;
    }

//	public ArrayList<TaskTodoInfo> getTaskTodoInfoList() {
//		return taskTodoInfoList;
//	}
//
//	public void setTaskTodoInfoList(ArrayList<TaskTodoInfo> taskTodoInfoList) {
//		this.taskTodoInfoList = taskTodoInfoList;
//	}

    public ArrayList<PaymentData> getPaymentListCatch() {
        return paymentListCatch;
    }

    public void setPaymentListCatch(ArrayList<PaymentData> paymentListCatch) {
        this.paymentListCatch = paymentListCatch;
    }

    public ArrayList<BorrowData> getBorrowData() {
        return borrowListCatch;
    }

    public void setBorrowData(ArrayList<BorrowData> borrowData) {
        this.borrowListCatch = borrowData;
    }

    public ArrayList<PurchaseData> getPurchaseListCatch() {
        return purchaseListCatch;
    }

    public void setPurchaseListCatch(ArrayList<PurchaseData> purchaseListCatch) {
        this.purchaseListCatch = purchaseListCatch;
    }

    public ArrayList<SealuseData> getSealuseData() {
        return sealuseListCatch;
    }

    public void setSealuseData(ArrayList<SealuseData> sealuseData) {
        this.sealuseListCatch = sealuseData;
    }

    public ArrayList<NoticeData> getNoticeListCatch() {
        return noticeListCatch;
    }

    public void setNoticeListCatch(ArrayList<NoticeData> noticeListCatch) {
        this.noticeListCatch = noticeListCatch;
    }

    public ArrayList<NoticeData> getNoticeList() {
        return noticeList;
    }

    public void setNoticeList(ArrayList<NoticeData> noticeList) {
        this.noticeList = noticeList;
    }

    public ArrayList<OverTimeData> getOvertimeListCatch() {
        return overtimeListCatch;
    }

    public void setOvertimeListCatch(ArrayList<OverTimeData> overtimeListCatch) {
        this.overtimeListCatch = overtimeListCatch;
    }

    public ArrayList<LeaveData> getLeaveListCatch() {
        return leaveListCatch;
    }

    public void setLeaveListCatch(ArrayList<LeaveData> leaveListCatch) {
        this.leaveListCatch = leaveListCatch;
    }

    public ArrayList<OutData> getOutListCatch() {
        return outListCatch;
    }

    public void setOutListCatch(ArrayList<OutData> outListCatch) {
        this.outListCatch = outListCatch;
    }

    public ArrayList<BusniessTravelData> getBusinessListCatch() {
        return businessListCatch;
    }

    public void setBusinessListCatch(ArrayList<BusniessTravelData> businessListCatch) {
        this.businessListCatch = businessListCatch;
    }

    public ArrayList<UserInfoData> getSignListCatch() {
        return signListCatch;
    }

    public void setSignListCatch(ArrayList<UserInfoData> signListCatch) {
        this.signListCatch = signListCatch;
    }

    public interface TaskUpdata {
        public void update(boolean error);
    }

}
